articles

Home / DeveloperSection / Articles / HTML Graphics using HTML

HTML Graphics using HTML

HTML Graphics using HTML

Ashutosh Kumar Verma 212 10-Jun-2024

HTML Graphics 

HTML obviously limits graphics, as HTML is mainly used for content organization and presentation rather than complex graphics. However, you can still create simple graphics with HTML and CSS, especially with the help of basic shapes, colors, and positioning.

Example- 

Here is a basic example to demonstrate HTML graphics design using HTML and CSS

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML Graphics Example</title>
    <style>
        /* CSS styles for the circle */
        .circle {
            width: 100px;
            height: 100px;
            background-color: red;
            border-radius: 50%; /* Creates a circle */
        }
       /* CSS styles for the rectangle */
        .rectangle {
            width: 150px;
            height: 100px;
            background-color: blue;
        }
        /* CSS styles for the triangle */
        .triangle {
            width: 0;
            height: 0;
            border-left: 50px solid transparent;
            border-right: 50px solid transparent;
            border-bottom: 100px solid green;
        }
    </style>
</head>
<body>

<h2>HTML Graphics Example</h2>

<!-- Simple shapes created using HTML and CSS -->
<div class="circle"></div>
<div class="rectangle"></div>
<div class="triangle"></div>

</body>
</html>

In the example above-

  • The red circle is created using a div element with a rectangular circle, and its appearance is defined using CSS methods.
  • The blue rectangle is created using the div element of the class rectangle.
  • The green rectangle is created using a div element with rectangular rectangles, and its appearance is defined using CSS borders.

 

Output- 

HTML Graphics using HTML


While basic shapes and simple graphics can be created using HTML and CSS, for more complex and dynamic graphics you will often use, or consider using, a JavaScript library such as SVG (Scalable Vector Graphics) or canvas graphics software will be used to export images for display on your website.

 

Also, Read: How to display Base64 images in HTML


Updated 10-Jun-2024
Hi! This is Ashutosh Kumar Verma. I am a software developer at MindStick Software Pvt Ltd since 2021. I have added some new and interesting features to the MindStick website like a story section, audio section, and merge profile feature on MindStick subdomains, etc. I love coding and I have good knowledge of SQL Database.

Leave Comment

Comments

Liked By